package white;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class getEmpDetail {

	public static String getEmpD() {
		String str = "";

		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		String url = "jdbc:oracle:thin:@192.168.3.24:1521:xe";
		String id = "test";
		String pwd = "test";
		String driver = "oracle.jdbc.driver.OracleDriver";
		String query = "select deptno,deptname from DEPTINFO";
		try {
			Class.forName(driver);
			conn = DriverManager.getConnection(url, id, pwd);
			pstmt = conn.prepareStatement(query);
			rs = pstmt.executeQuery();
			String text = "", code = "";
			while (rs.next()) {
				code += rs.getString("deptno") + "|";
				text += rs.getString("deptname") + "|";
			}
			code = code.substring(0, code.length() - 1);
			text = text.substring(0, text.length() - 1);
			str = text + "@@" + code;
		} catch (Exception ex) {

		} finally {
			try {
				rs.close();
				pstmt.close();
				conn.close();
			} catch (Exception e) {

			}
		}

		return str;

	}

}
